<template>
  <div>
    <a-page-header
      title="能源消费企业排名"
      style="background: #FFFFFF;padding: 16px 24px 0"
    />
    <a-card :bordered="false">
      <!-- 查询区域 -->
      <div class="table-page-search-wrapper">
        <a-form layout="inline">
          <a-row type="flex">
            <a-col>
              <a-button icon="plus" style="margin-right: 20px" type="primary" @click="openAdd()">新增</a-button>
              <a-divider style="margin-right: 20px" type="vertical" />
            </a-col>
            <a-col :sm="7" md="5" style="margin-left: 15px">
              <a-form-item label="企业名称">
                <j-input v-model="queryParam.enterpriseName" placeholder="请输入企业名称"></j-input>
              </a-form-item>
            </a-col>
            <a-col :md="5" :sm="7" style="margin-left: 15px">
              <a-form-item label="年份">
                <a-select v-model="queryParam.year" placeholder="请选择年份">
                  <a-select-option v-for="(i,index) in yearList" :key="index" :value="i.key">{{ i.name }}
                  </a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col flex="auto" style="margin-left: 15px">
            <span class="table-page-search-submitButtons" style="float: left; overflow: hidden;margin-right: 20px">
              <a-button icon="search" style="margin-left: 10px" type="primary" @click="searchQuery">查询</a-button>
              <a-popover :overlayStyle="{background: 'white'}" placement="topLeft">
                <template slot="content">
                  <a-icon theme="twoTone" two-tone-color="#52c41a" type="exclamation-circle" /><span
                  style="margin-left: 5px">可以点击重置来重新筛选结果</span>
                </template>
                <a-button
                  icon="reload"
                  style="margin-left: 8px"
                  @click="searchReset"
                >重置</a-button>
              </a-popover>
            </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
      <div>
        <a-table
          ref="table"
          :columns="columns"
          :dataSource="dataSource"
          :loading="loading"
          :pagination="ipagination"
          :scroll="{ x: 2000 }"
          bordered
          rowKey="id"
          size="middle"
          @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
          <a-button style="margin-right: 10px" type="primary" @click="handleEdit(record)">
            编辑
          </a-button>
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
              <a-button>
                删除
              </a-button>
            </a-popconfirm>
        </span>
        </a-table>
        <!--      <eng-consumption-modal ref="modalForm" @ok="modalFormOk"></eng-consumption-modal>-->
        <enterprise-rank-modal ref="modalForm" @ok="modalFormOk"></enterprise-rank-modal>

      </div>
    </a-card>
  </div>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JInput from '@comp/jeecg/JInput'
import EnterpriseRankModal from '@views/dataVisualization/components/enterpriseRankModal'

const date = new Date()
const count = date.getFullYear() - 2020
const yearlist = []
for (let i = 0; i < count + 1; i++) {
  yearlist.push({
    name: date.getFullYear() - i,
    key: date.getFullYear() - i
  })
}

export default {
  name: 'enterpriseRanking',
  mixins: [JeecgListMixin],
  components: {
    EnterpriseRankModal,
    JInput
  },
  data() {
    return {
      yearList: yearlist,
      confirmLoading: false,
      title: '',
      visible: false,
      dataSource: [],
      form: this.$form.createForm(this),
      dialogStyle: {
        top: '200px'
      },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      columns: [

        {
          title: '地区',
          align: 'center',
          dataIndex: 'area',
          width: 150
        },
        {
          title: '企业名称',
          align: 'center',
          dataIndex: 'enterpriseName',
          width: 250
        },
        {
          title: '社会统一信用代码',
          align: 'center',
          dataIndex: 'enterpriseUscc'
        },
        {
          title: '能耗（吨）',
          align: 'center',
          dataIndex: 'eneygyNum',
          width: 150
        },
        {
          title: '排放量（吨）',
          align: 'center',
          dataIndex: 'carbonNum',
          width: 150
        },
        {
          title: '行业大类',
          align: 'center',
          dataIndex: 'industryType',
          width: 80
        },
        {
          title: '细分行业',
          align: 'center',
          dataIndex: 'mince'
        },
        {
          title: '煤',
          align: 'center',
          dataIndex: 'coal',
          width: 120
        },
        {
          title: '油',
          align: 'center',
          dataIndex: 'oil',
          width: 120
        },
        {
          title: '气',
          align: 'center',
          dataIndex: 'gas',
          width: 120
        },
        {
          title: '电',
          align: 'center',
          dataIndex: 'electricity',
          width: 120
        },
        {
          title: '蒸汽',
          align: 'center',
          dataIndex: 'steam',
          width: 120
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' },
          width: 200,
          fixed: 'right'
        }
      ],
      url: {
        list: '/carbon/enterpriseFileConsumptionRankList/list',
        delete: '/carbon/enterpriseFileConsumptionRankList/delete',
      }
    }
  },
  methods: {
    openAdd() {
      this.$refs.modalForm.add()
      this.$refs.modalForm.title = '新增'
      this.$refs.modalForm.disableSubmit = false
    }
  }
}
</script>

<style scoped>

</style>